package com.talent.service.order.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.talent.model.entity.order.TlOrder;
import com.talent.service.base.user.UserFeign;
import com.talent.service.order.mapper.OrderMapper;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @ClassName：OrderServiceImpl
 * @Author: hszhou
 * @Date: 2025/2/27 17:48
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Service
@RequiredArgsConstructor
public class OrderServiceImpl  extends ServiceImpl<OrderMapper, TlOrder>implements IOrderService{




    private final UserFeign userFeign;
    @Override
    @GlobalTransactional(rollbackFor = Exception.class)
    public TlOrder createOrder(Long userId, Long productId) {

        TlOrder tlOrder = new TlOrder();
        tlOrder.setUserId(userId);
        tlOrder.setProductName("productName");
        tlOrder.setPrice(BigDecimal.TEN);
        tlOrder.setUsername("111");
        save(tlOrder);
        userFeign.userInfo(userId);
        return tlOrder;
    }
}
